# 剑指 Offer 53 - I. 在排序数组中查找数字 I
# 统计一个数字在排序数组中出现的次数。

 

# 示例 1:

# 输入: nums = [5,7,7,8,8,10], target = 8
# 输出: 2
# 示例 2:

# 输入: nums = [5,7,7,8,8,10], target = 6
# 输出: 0
 

# 提示：

# 0 <= nums.length <= 105
# -109 <= nums[i] <= 109
# nums 是一个非递减数组
# -109 <= target <= 109

class Solution:
    def search(self, nums: List[int], target: int) -> int:
        res = 0
        for i in range(len(nums)):
            if nums[i] != target:
                continue
            res += 1
            for j in range(i + 1, len(nums)):
                if nums[j] == target:
                    res += 1
                else:
                    break
            break
        return res